<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Klenwell Javascript Test</title>

<!-- Internal Script -->
<script type="text/javascript">
function div_write(str, inline_style)
{
	document.write('<div style="' + inline_style + '">' + str + '</div>');
	return;
}


var global_timer_started = 0;
var global_tx0 = 0;
function js_timer() 
{
	if ( !global_timer_started )
	{
		global_timer_started = 1;
		global_tx0 = new Date();
		return;
	}
	else
	{
		var tx_now = new Date();
		return ( tx_now - global_tx0 ) / 1000; 
	}
}
js_timer();

function js_waste_time()
{
 var html = "";
 for ( var i=0; i<10000; i++ )
 {
  html += "<table><tr><td>" + i + "</td></td></table>";
 }
 div_write(html);
}
</script>

<!-- External Script -->
<script type="text/javascript" src="../encryption/rc4.js"></script>
<script type="text/javascript" src="../encryption/md5.js"></script>

<style type="text/css">
body
{
 margin:0; padding:0;
 font-family:sans-serif;
}
h1#page_title
{
 margin:0 0 10px;
 padding:1em;
 color:ccf;
 border-bottom:1px solid #ccf;
 background: #f3f3ff;
}
#testbed
{
 width:60%; margin:1em auto; padding:1em;
 font-family:monocode;
 border:1px solid #ccc;
}
#footer
{
 clear:both;
 padding:4px;
 font: 11px verdana,sans-serif;
 color:ccf;
 border:1px solid #ccf;
 border-width:1px 0;
 background: #f3f3ff;
 text-align:center;
}
</style>

</head>
<body>

<h1 id="page_title">rc4 test</h1>

<div id="testbed">

<script type="text/javascript">
var div_style = "font-size:.8em; padding-bottom:.5em;";

var the_key = hexMD5('the key');
var plaintext = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
div_write('the plaintext: ' + plaintext, div_style);
div_write('the key: ' + the_key, div_style);

var encypted_text = rc4_encrypt(the_key, plaintext);
div_write('encrypted: ' + encypted_text, div_style);

var disencypted_text = rc4_decrypt(the_key, encypted_text);
div_write('decrypted: ' + disencypted_text, div_style);

var strlen_plain = plaintext.length;
var strlen_crypt = encypted_text.length;
div_write('plaintext strlen: ' + strlen_plain, div_style);
div_write('crypt strlen: ' + strlen_crypt, div_style);

var script_time = js_timer();
var crypt_rate = strlen_plain / script_time;
div_write('encrypt rate: ' + crypt_rate + ' chars/sec', div_style);
</script>

</div>

<script type="text/javascript">div_write('<div id="footer">js timer: ' +  js_timer() + ' s</div>');</script>

</body>
</html>
